Skip to content

Fix self-host DatasetMeta serialization and offline base-model alias resolution#231

Open
kevssim wants to merge 2 commits into
modelscope:mainfrom
kevssim:fix_dataset
Open

Fix self-host DatasetMeta serialization and offline base-model alias resolution#231
kevssim wants to merge 2 commits into
modelscope:mainfrom
kevssim:fix_dataset

Conversation

@kevssim

@kevssim kevssim commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

This PR fixes two self-host client/server issues.

  1. Fix DatasetMeta HTTP serialization failure.

DatasetMeta was serialized from __dict__, which included the runtime-only _uid field. When the processor service deserialized that payload and rebuilt DatasetMeta, server-side processor creation failed with:

TypeError: DatasetMeta.__init__() got an unexpected keyword argument '_uid'

This PR changes the serialization path to only include declared dataclass fields and filters unexpected/private fields during deserialization. That fixes both newly generated payloads and stale payloads that may still contain _uid.

  1. Fix offline self-host template initialization when client only knows the public base model name.

Previously, dataset.set_template(..., model_id='Qwen/Qwen3.5-4B') failed in offline self-host deployments because template initialization treated model_id as a real local path or a hub model id. In practice, the client may only know the public model name, while the server is configured to load the actual model from a local path such as /nas/disk1/Qwen3-8B.

This PR adds server-side model alias resolution:

  • build a public model name -> real model_id/path alias map from model deployment config
  • propagate that alias map to Ray worker processes through TWINKLE_MODEL_ID_ALIASES
  • resolve aliases inside HubOperation.download_model() before local path or hub resolution

With this change, client code can continue using:

dataset.set_template('Qwen3_5Template', model_id='Qwen/Qwen3.5-4B', max_length=512)

as long as the server deployment is configured with a matching route and real local model path.

Files changed:

  • src/twinkle_client/common/serialize.py
  • src/twinkle/hub/model_alias.py
  • src/twinkle/hub/hub.py
  • src/twinkle/hub/__init__.py
  • src/twinkle/server/launcher/server_launcher.py
  • src/twinkle/server/launcher/env_propagation.py

@kevssim kevssim requested a review from Yunnglin June 22, 2026 07:06

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for model ID aliases by adding a new model_alias module, integrating alias resolution into the model downloading process, and propagating the alias mapping via environment variables. It also refactors DatasetMeta serialization to dynamically filter fields. The review feedback highlights several excellent optimization opportunities, such as caching the dataclass fields as a module-level constant to avoid dynamic lookup overhead, using strip('/') to robustly handle trailing slashes in route prefixes, and avoiding redundant dictionary copies when resolving aliases.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/twinkle_client/common/serialize.py Outdated
Comment thread src/twinkle_client/common/serialize.py Outdated
Comment thread src/twinkle_client/common/serialize.py Outdated
Comment thread src/twinkle/hub/model_alias.py Outdated
Comment thread src/twinkle/hub/model_alias.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant